#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Time       :   17:32
# Author     : Y4
# Site       : 
# File       : 007 线程.py
# Software   : PyCharm

'''
创建线程   如何使用线程

线程状态
    新建
    就绪
    运行
    阻塞
    结束

线程是可以共享全局变量.进程不可以

'''


from multiprocessing import Process

import threading
from time import sleep


def download(n):
    images = ['1.jpg','2.jpg','3.jpg','4.jpg','5.jpg']
    for i in images:
        print('正在下载,{}'.format(i))
        sleep(n)
        print("下载{}成功".format(i))

def listenMusic(n):
    music = ['1.mp3', '2.mp3', '3.mp3', '4.mp3', '5.mp3']
    for i in music:
        sleep(n)
        print('正在听歌,{}'.format(i))


if __name__ == '__main__':
    # 线程对象
    t = threading.Thread(target=download, name="下载", args=(1,))
    t.start()

    t1 = threading.Thread(target=listenMusic, name="听歌", args=(0.5,))
    t1.start()




